Author Topic: Can't change TI delimiters  (Read 4138 times)

0 Members and 1 Guest are viewing this topic.

Offline AutoFetishist

  • Sr. Member
  • ****
  • Posts: 397
  • Karma: 2
  • Gender: Male
Re: Can't change TI delimiters
« Reply #10 on: April 21, 2011, 01:54:22 PM »
Right-O

I have this code, which will insert a nonbreaking space between the last and the second-to-last word of each paragraph:


     tell window 1
          repeat with p from 1 to (count of paragraphs)
               set theText to text of paragraph p
               try
                    set theNewText to (text items 1 thru -2 of theText) as string
                    set theNewText to theNewText & "<\\!s>" & text item -1 of theText
               end try
               try
                    set text of paragraph p to theNewText
               end try
          end repeat
     end tell

which I want to run after tagging text with Xpress tag-stylesheets.
Which are normally in blue code, for readability.
But of course I don't want to insert "<\\!s>" in the middle of any code that is blue.

Hence my reason for wanting to search/replace only within black text.

Offline Publi-Script

  • Administrator
  • Hero Member
  • *****
  • Posts: 596
  • Karma: 16
  • Gender: Male
  • Automate your Life!
    • Publi-Script.com
Re: Can't change TI delimiters
« Reply #11 on: April 21, 2011, 01:58:49 PM »
Any example of before and after text results?
Michel Lemieux
Forum Administrator
-------------------------
OS X 10.6.4
Quark 6.5 / 7.5 / 8.1.6
Adobe Design Premium CS / CS2 / CS3 / CS4 / CS5
Script Debugger 4.5

Offline AutoFetishist

  • Sr. Member
  • ****
  • Posts: 397
  • Karma: 2
  • Gender: Male
Re: Can't change TI delimiters
« Reply #12 on: April 21, 2011, 03:38:07 PM »
Sure:

@11c - NTFS Head:Summary
@11c - NTFS Body:The following is a summary of the Fund’s holdings as categorized under the three-tier hierarchy of inputs used in valuing the Fund’s assets.
@11c - NTFS Body:Class N shares are sold only through retirement plans. Retirement plans that offer Class N shares may impose charges on those accounts. All classes of shares have identical rights and voting privileges with respect to the Fund in general and exclusive voting rights on matters that affect that 72 months after the date of purchase.
@11c - NTFS Body:The following is a summary of significant accounting policies consistently followed by the Fund.
@11c - NTFS w Run In:Securities Valuation. The Fund calculates the net asset value of its shares as of the close of the New York Stock Exchange (the “Exchange”), normally 4:00 P.M. Eastern time, on each day the Exchange is open for trading.

Offline Publi-Script

  • Administrator
  • Hero Member
  • *****
  • Posts: 596
  • Karma: 16
  • Gender: Male
  • Automate your Life!
    • Publi-Script.com
Re: Can't change TI delimiters
« Reply #13 on: April 21, 2011, 03:43:57 PM »
This is the "before" ???

What is the desired end result?
Michel Lemieux
Forum Administrator
-------------------------
OS X 10.6.4
Quark 6.5 / 7.5 / 8.1.6
Adobe Design Premium CS / CS2 / CS3 / CS4 / CS5
Script Debugger 4.5

Offline AutoFetishist

  • Sr. Member
  • ****
  • Posts: 397
  • Karma: 2
  • Gender: Male
Re: Can't change TI delimiters
« Reply #14 on: April 21, 2011, 04:10:00 PM »
That was the before.


This would be what I would want after doing my search/replace for the last space of each line:
(The key being to ignore the blue type when searching/replacing):
 
@11c - NTFS Head:Summary
@11c - NTFS Body:The following is a summary of the Fund’s holdings as categorized under the three-tier hierarchy of inputs used in valuing the Fund’s<\!s>assets.
@11c - NTFS Body:Class N shares are sold only through retirement plans. Retirement plans that offer Class N shares may impose charges on those accounts. All classes of shares have identical rights and voting privileges with respect to the Fund in general and exclusive voting rights on matters that affect that 72 months after the date of<\!s>purchase.
@11c - NTFS Body:The following is a summary of significant accounting policies consistently followed by the<\!s>Fund.
@11c - NTFS w Run In:Securities Valuation. The Fund calculates the net asset value of its shares as of the close of the New York Stock Exchange (the “Exchange”), normally 4:00 P.M. Eastern time, on each day the Exchange is open for<\!s>trading.

Offline Publi-Script

  • Administrator
  • Hero Member
  • *****
  • Posts: 596
  • Karma: 16
  • Gender: Male
  • Automate your Life!
    • Publi-Script.com
Re: Can't change TI delimiters
« Reply #15 on: April 22, 2011, 11:33:37 PM »
Try this:
Quote
001   tell application "Tex-Edit Plus"
002      tell document 1
003         repeat with p from 1 to count of paragraph
004            set originalBlackText to (last style run of paragraph p whose color is black)
005            set text of (last style run of paragraph p whose color is black) to my modifyText(originalBlackText)
006         end repeat
007      end tell   
008   end tell

009   on modifyText(textToModify)
010      repeat with c from textToModify's length to 1 by -1
011         if character c of textToModify is space then
012            set textToModify to text 1 thru (c - 1) of textToModify & "<\\!s>" & text (c + 1) thru -1 of textToModify
013            exit repeat
014         end if
015      end repeat
016      return textToModify
017   end modifyText
Note:
• The line numbers included with this script are there to aid future discussions. In order to use this script, you will have to strip all of them.
Michel Lemieux
Forum Administrator
-------------------------
OS X 10.6.4
Quark 6.5 / 7.5 / 8.1.6
Adobe Design Premium CS / CS2 / CS3 / CS4 / CS5
Script Debugger 4.5