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

GREP > finding roman brackets next to italic character or numeral

Return to Member Forum

  • Author
    Posts
    • #1227157
      Ryan Scheife
      Member

      Hi all.

      I have a monumental task of weeding through thousands of instances of bracketed text to assure text that begins and ends in italics in this bracketed text is enclosed by italic brackets (and not roman). In some cases I need to do the opposite (assure beginning and closing brackets are styled in roman where starting or ending text enclosed are styled roman). Specifically:

      “When the enclosed material begins and ends in italic but contains roman text in between, italic enclosures may be used. If only one end of the enclosed material is italic, however, the parentheses or brackets should be roman.”

      I cannot find a way to search in my document roman brackets next to an italic character or numeral, or visa versa. Does anyone have any suggestions here?

      Thanks for any guidance. —Ryan

    • #14323143
      Brian Pifer
      Participant

      Disclaimer: GREP is not my strong suit, but I think this can be accomplished via script. The following will find all bracketed content, and compare the brackets to the first and last characters within the brackets to compare their applied fonts. Not sure if my app.findGrepPreferences.findWhat line will match exactly all the time — if you already have a good GREP you’re using, feel free to sub it in (add an additional escape backslash for the script purposes. I haven’t fully tested, but you can give it a shot.

      var doc = app.activeDocument;

      app.findGrepPreferences = NothingEnum.NOTHING;
      app.changeGrepPreferences = NothingEnum.NOTHING;
      app.findGrepPreferences.findWhat = “[(w*| *){1,}]”;
      var finds = doc.findGrep();

      for (var i = 0; i < finds.length; i++) {
      var firstBrack = finds[i].characters[0];
      var lastBrack = finds[i].characters[-1];
      var firstChar = finds[i].characters[1];
      var lastChar = finds[i].characters[-2];
      if (firstChar.appliedFont.fullName.toLowerCase().indexOf(“italic”) >= 0 && lastChar.appliedFont.fullName.toLowerCase().indexOf(“italic”) >= 0)
      {
      firstBrack.appliedFont = firstChar.appliedFont;
      lastBrack.appliedFont = firstChar.appliedFont;
      }
      else if (firstChar.appliedFont.fullName.toLowerCase().indexOf(“italic”) == -1 && lastChar.appliedFont.fullName.toLowerCase().indexOf(“italic”) == -1) {
      firstBrack.appliedFont = firstChar.appliedFont;
      lastBrack.appliedFont = firstChar.appliedFont;
      }
      }

      app.findGrepPreferences = NothingEnum.NOTHING;
      app.changeGrepPreferences = NothingEnum.NOTHING;

Viewing 1 reply thread
  • You must be logged in to reply to this topic.
Forum Ads