🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: adobe.scripting.indesign
Article #18451

Re: AS. Search and replace text with different paragraph styles

#18451
From: Dave Saunders
Date: Wed, 26 Mar 2003 17:58
28 lines
1994 bytes
Roy,

If I understand you, every instance of "@" signifies a place where your paragraph style must "split" and you want to delete the "@" after making the styling change.

Now, that sentence was PageMaker speak.

In InDesign, what you want to do is set a character style to all the text up to the "@" and then delete the "@".

So, I'll call the character style "runin".

Your script must search for every instance of "@" and then process them backwards (so that deleting one doesn't destroy the references to the unprocessed paragraphs).

tell application "InDesign 2.0.2"
 set myCharStyle to character style "runin" of document 1
 set find preferences to nothing
 set myAts to search document 1 for "@"
 repeat with n from count of myAts to 1 by -1
  set myStory to parent story of item n of myAts
  set myIndex to index of item n of myAts
  set myParaIndex to index of paragraph 1 of of item n of myAts
  set applied character style of characters myParaIndex through myIndex of myStory to myStyle
  delete character myIndex of myStory
 end repeat
end tell

This script does the job provided that you set up the character style before running it.

Dave
Technical Details
Message-ID: <1de8743a.2@WebX.la2eafNXanI>
Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-02!sn-xit-06!sn-xit-08!supernews.com!diablo.theplanet.net!newsfeed.icl.net!newsfeed.fjserv.net!news.tele.dk!news.tele.dk!small.news.tele.dk!eusc.inter.net!newsfeed01.sul.t-online.de!t-online.de!WebX
References: <1de8743a.-1@WebX.la2eafNXanI>

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: f939a,84b62141db21aa59
X-Google-Attributes: gidf939a,public
X-Google-ArrivalTime: 2003-03-26 10:08:06 PST
From: "Dave Saunders" <daves@pdsassoc.com>
Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-02!sn-xit-06!sn-xit-08!supernews.com!diablo.theplanet.net!newsfeed.icl.net!newsfeed.fjserv.net!news.tele.dk!news.tele.dk!small.news.tele.dk!eusc.inter.net!newsfeed01.sul.t-online.de!t-online.de!WebX
Newsgroups: adobe.scripting.indesign
Subject: Re: AS. Search and replace text with different paragraph styles
Message-ID: <1de8743a.2@WebX.la2eafNXanI>
Date: Wed, 26 Mar 2003 09:58:19 -0800
References: <1de8743a.-1@WebX.la2eafNXanI>
Lines: 35
MIME-Version: 1.0
Content-Type: text/plain; charset="ISO-8859-1"
Content-Transfer-Encoding: 8bit