Back

If your email is not recognized and you believe it should be, please contact us.

  • You must be logged in to reply to this topic.Login

Possible to find unstyled character(s) touching styled characters on either/both sides?

Return to Member Forum

  • Author
    Posts
    • #62376
      Olaf Nelson
      Member

      I've read everything I can find in this forum and on the web, but I haven't found what I'm looking for.

      I've got a book with thousands and thousands of words, phrases, titles, sentences, etc., set in my italic character style (actually 2 styles, because the footnote italics are a different size than the body italics). Very often certain characters (some diacritics used for Arabic transliteration, commas, periods and more) are not italicized when they're within or at either end of italic words. I think it's an artifact of how the author wrote it in Word. I need to put these characters into the appropriate italic style.

      In order to make it easier to spot them, I temporarily give my italic character styles different colors so they stand out from the black regular text.

      I could go through and do it manually, but that would take days and I'd end up in jail.

      If I could search for any character with no style touching a styled character and then replace the unstyled one with the style of the other one, that would do it for the body text.

      The footnote might be trickier, since the regular text in the notes is a character style. I don't know why it's that way.

      Or, if I could search for anything black that touches something not-black and change the black thing to the style of the not0black thing, that would also work.

      I'm hoping GREP can do what I need, but I haven't been able to make it work.

      Thanks!

    • #62377

      A tricky one indeed.

      I could search for anything black that touches something not-black and change the black thing to the style of the not0black thing, that would also work.

      A good idea. Try this: put [Black] in the Find formatting field, and look for

      (?s).(?!.)

      This will look for Black characters where there is “nothing” following. It should work, because it seems ID treats “not the same formatting” as “nothing”.

      It needs the Ignore Hard Return flag (?s) because the end of a paragraph is also considered “nothing” in default mode.

    • #62378

      Oh, and the second part, “change to whatever is next” is not possible with a straight search-and-replace. So you have to put formatting #1 in the replace and step manually through the file, changing or not, and repeat for formatting #2.

      Perhaps it could be done if you first set style #1 to colored and leave the other ones at black.

    • #62379
      Olaf Nelson
      Member

      Thanks, Jongware!

      That works great for anything that's at the beginning or in the middle of a string of styled characters. It doesn't pick up the ones that are at the end, though, and I don't think you meant it to. Can it be modified to do so? That would pick up the end-of-word diacritics and the commas.

      The only other downside is that it finds every space that's before a styled character, of which there are probably tens of thousands. Still better than scrolling through doing it by eye. Far better.

      Thanks!

    • #62380
      Olaf Nelson
      Member

      It also finds the period at the end of every footnote (the invisible character # must be the different formatted thing it's finding) and every superscripted footnote reference. Not sure if it's possible to have multiple ignores in a query.

    • #62381

      No, you cannot add “ignore” stuff. ID can easily search for things but not for not-something.

      To not find a space in the above, try this one:

      (?s)S(?!.)

      The GREP code S is the inverse of “every kind of whitespace”. This will locate the black-followed-by-nots, try this for the reverse order:

      (?s)(?<!.)S

      These codes also find the end of footnotes, table cells, and stories, not because “the formatting is different” but because that also qualifies as “text, followed by nothing”. I think it stopping right before a footnote could qualify as a Real bug — why doesn't it “eat” the footnote marker as a single character and continue!? (Someone forgot to treat the code as “special”, I guess.)

      Theoretically, you can put all both queries above in one single long GREP, like this:

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

      I hope I got the right number of opening and closing parens! If I got it wrong, it'll just tell you “Not Found”.

    • #62382
      Olaf Nelson
      Member

      By changing (?s).(?!.) to (?s)w(?!.) I can avoid it finding spaces, final periods and footnote references. Of course I'll have to do it differently for punctuation after styled characters (mostly commas) that needs to be found.

      In the half hour I've been using this search I've saved at least a couple hours, so even if I have to scan through for the end-of-word diacritics and do them manually, this GREP help has already added quality time to my life.

    • #62383
      Olaf Nelson
      Member

      Your reply came in while I was typing my last one (about changing . to w), so now I'll go try the new ones you've provided.

      Thanks

    • #62384

      Ha ha! I re-read my post to check for inconsistincies, and I immediately spotted these contradicting statements:

      No, you cannot add “ignore” stuff. ID can easily search for things but not for not-something.

      To not find a space in the above, try this one:

      Let me expand a bit. You can search for characters in a set, or for characters not in a set. It's just formatting where you can search for a presence or an absence of, and then only for the entire search string.

    • #62385
      Olaf Nelson
      Member

      The query (?s)(S(?!.))|((?<!.)S) is working beautifully (after I took an extra “)” off the end of it) for offending characters before, during and after styled ones. It's not finding spaces, which is great. It does find the footnote references, as expected. Is there a way to exclude numbers? I don't think there will ever be a situation in this book where a number would need to be found.

      As you said it would, it does still find the end of notes. I can live with that. It just means a few hundred extra clicks and that's nothing compared to the number of clicks I'm saving! Besides, a fairly short session browsing fishing gear online while avoiding the drudgery of finding unstyled commas might take a few hundred clicks without my even noticing it, and all the time you've saved me can theoretically be spent fishing instead working (or avoiding work).

    • #14323614
      Olaf Nelson
      Member

      Resurrecting this old topic as I now can’t get any of the above to work.

      Before I found this old topic I was going to post the following as a new one:

      Some of the publishers I work for require that parentheses be italicized if the text immediately inside BOTH of them is italic (even if not all text inside is). The writers and editors don’t seem to get it, so I end up with a lot of pairs that are not italic at all when they should be, other pairs with one of each, etc. I would like to be able to do a search for any PAIR of ( and ) where the ( is followed by an italic character AND the ) is preceded by an italic character.
      Other publishers I work for require that no parentheses be italicized unless they’re within a string of text that is italic inside AND outside of them. I guess that would be a similar operation, though non-italic spaces or punctuation immediately outside the parentheses could mess it up.

      It would be nice to be able to do the same thing to look for italic (or bold etc.) characters followed immediately by , ? ! etc. that need to be italicized. I asked about this at PepCon in Chicago years ago and was told there’s no way to do it because it involves searching for multiple styles at once. In other words, you can search for a string in italics that’s followed by a comma, but won’t find any where the comma isn’t also italic. This is pretty much what Jongware was helping with above.

      Similar to what I said in the first post of this thread, I’ve been doing it with character styles by making an italic style that’s a bright color (or highlighted using a fat offset colored underline) and another style in a contrasting color that gets applied to all the parentheses (or commas or whatever). Then I have to look through the whole thing for places where they butt up against each other. A search would be better for many reasons.

      Quite a few years went by where I didn’t need to do this, so I don’t know whether something in ID has changed that makes Jongware’s suggestions not work or I’m just forgetting some small step in the process.

    • #14362063
      Olaf Nelson
      Member

      I just posted this as a comment (https://creativepro.com/how-to-find-and-fix-partially-italic-words-with-grep/#comments/2417197) on Mike Rankin’s post about fixing partially italicized words (https://creativepro.com/how-to-find-and-fix-partially-italic-words-with-grep/) but thought I should add it here so it has a better chance of helping someone else and of being seen by someone who has the GREP expertise to make my simple queries more powerful, flexible, or efficient.

      I took Mike’s queries and, with very little experimentation, found preliminary solutions to this problem I’ve wanted to solve since I started using InDesign (either ID 2.0 or CS, 2003-ish, when I’d never heard of GREP and don’t even know if ID had it). As I mentioned above in this thread, Jongware’s expressions no longer work for me.

      I’m sure these can be made more powerful or more efficient, but I’m ecstatic at the results I got from 5 minutes of effort.

      For the parentheses issue I searched for [\S]+ (Mike’s search) but altered the Change To field to put non-joiners both before AND after the italics: ~j$0~j.
      Then I did a find query that looks for ( followed by a non-joiner OR a non-joiner followed by ) and changes it to italics: ((\()(~j)|(~j)(\)))

      I’d love to be able to have it look for (~j, check to see whether the closing ) is preceded by ~j, and change them both ONLY if both are matches (change nothing if only one matches). Possible? (Would also be useful for quotation marks around italic text, but would have to account for punctuation inside the closing one.)

      To address the commas/semicolons/colons issue that has haunted me for 20 years, I first ran Mike’s search to put a non-joiner after italic text, then searched for non-joiners followed by one of those: (~j)(,|;|:) with my italic character style in the Change Format box. I’ll have to add more punctuation to the search.

      These are going to save me a ton of time–even though I’ll probably never be confident enough to click Change All. On some books this has taken me a full day—or more—and I always knew I probably missed some and/or changed some I shouldn’t have.
      Huge thanks to Mike Rankin.

    • #14362065
      David Blatner
      Keymaster

      Olaf, I’m so pleased that this new technique is working for you. That’s awesome.

      As for Jongware’s expressions above… I think something may have become corrupted in there. I think it’s missing slashes, back-slashes, or they got replaced by ? characters… I’ll have to figure that out sometime.

      • #14362147
        Olaf Nelson
        Member

        That hadn’t occurred to me. Even if I don’t need them anymore, I wish I’d taken a screenshot back when they worked. Maybe if I opened all the old version of ID on my old computers I’d find the saved queries.

Viewing 12 reply threads
  • The forum ‘General InDesign Topics (CLOSED)’ is closed to new topics and replies.
Forum Ads