Author Topic: Another "restricted" search [TE+]  (Read 2214 times)

0 Members and 1 Guest are viewing this topic.

Offline AutoFetishist

  • Sr. Member
  • ****
  • Posts: 397
  • Karma: 2
  • Gender: Male
Another "restricted" search [TE+]
« on: December 15, 2010, 12:19:19 PM »
Based on this:

I want to perform a search/replace for the last 2 words of a paragraph, but only when they are black.

I want to make sure I'm not affecting my xpress tags, which I always have tagged bold/blue:

I tried to insert the following   
         if (styles of (text items 1 thru -2) = {style:{plain}, color:black} in paragraph p) > 2 then
but that doesn't compile.

Here's the script I want to modify:
tell application "Tex-Edit Plus"
     set AppleScript's text item delimiters to " "
     tell window 1
          repeat with p from 1 to (count of paragraphs)
               set theText to text of paragraph p
                    set theNewText to (text items 1 thru -2 of theText) as string
                    set theNewText to theNewText & "<\\!s>" & text item -1 of theText
                    set text of paragraph p to theNewText
               end try
          end repeat
     end tell
end tell
« Last Edit: December 15, 2010, 12:30:13 PM by AutoFetishist »