🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: adobe.scripting.indesign
Article #17820

Re: AS changing text attributes

#17820
From: Olav Kvern
Date: Mon, 12 May 2003 22:09
41 lines
2341 bytes
Kari--

This one seems to work with both single-item and multi-item lists:



tell application "InDesign 2.0.2" 
	set find preferences to nothing 
	set change preferences to nothing 
	tell active document 
		set myCharacterStyle to character style "bold" 
		repeat with myStory in stories 
			set myStartItems to search for "[BOLD]" 
			set myEndItems to search for "[UNBOLD]" 
			if (count myStartItems) is not equal to (count myEndItems) then 
				display dialog "Oops. The text must include mismatched formatting. Good luck finding the offending tags!" 
			else 
				repeat with myCounter from 1 to (count myStartItems) 
					set myStartItem to object reference of item myCounter of myStartItems 
					set myEndItem to object reference of item myCounter of myEndItems 
					set myStartIndex to (index of character -1 of myStartItem) + 1 
					set myEndIndex to (index of character 1 of myEndItem) - 1 
					set applied character style of characters myStartIndex through myEndIndex of myStory to myCharacterStyle 
				end repeat 
				repeat with myCounter from (count myStartItems) to 1 by -1 
					set myStartItem to object reference of item myCounter of myStartItems 
					set myEndItem to object reference of item myCounter of myEndItems 
					tell myEndItem to delete 
					tell myStartItem to delete 
				end repeat 
			end if 
		end repeat 
	end tell 
end tell 
</end>

Does it work for you? It's not speedy, due to the need to delete the tags in sequence, but it does seem to work.

Thanks,

Ole
Technical Details
Message-ID: <1de8dffa.12@WebX.la2eafNXanI>
Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-02!sn-xit-06!sn-xit-08!supernews.com!newsfeed.news2me.com!newsfeed.icl.net!newsfeed.fjserv.net!newsfeed.icl.net!newsfeed.fjserv.net!lnewspeer01.lnd.ops.eu.uu.net!emea.uu.net!newsfeed01.sul.t-online.de!t-online.de!WebX
References: <1de8dffa.-1@WebX.la2eafNXanI>

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: f939a,3f638a313e6d5906
X-Google-Attributes: gidf939a,public
X-Google-ArrivalTime: 2003-05-12 15:37:45 PST
From: "Olav Kvern" <okvern@adobe.com>
Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-02!sn-xit-06!sn-xit-08!supernews.com!newsfeed.news2me.com!newsfeed.icl.net!newsfeed.fjserv.net!newsfeed.icl.net!newsfeed.fjserv.net!lnewspeer01.lnd.ops.eu.uu.net!emea.uu.net!newsfeed01.sul.t-online.de!t-online.de!WebX
Newsgroups: adobe.scripting.indesign
Subject: Re: AS changing text attributes
Message-ID: <1de8dffa.12@WebX.la2eafNXanI>
Date: Mon, 12 May 2003 15:09:32 -0700
References: <1de8dffa.-1@WebX.la2eafNXanI>
Lines: 44
MIME-Version: 1.0
Content-Type: text/plain; charset="ISO-8859-1"
Content-Transfer-Encoding: 8bit